home *** CD-ROM | disk | FTP | other *** search
- /* 'Deep causal reasoning' diagnosis of car starting problems,
- based on Luc Steels article "Components of Expertise" in AI Magazine,
- Vol. 11, No. 2, 1990. */
-
- /*
- Backward chaining version (see CARFWD.KB for forward chaining version)
- */
-
- rule init forward /* Initialize working memory with problem */
- if start
- then
- remove start &
- add [transmission-ok, prereq, engine-starts] &
- add [starter-turning, prereq, engine-starts] &
- add [plug1-fires, prereq, engine-starts] &
- add [plug2-fires, prereq, engine-starts] &
- add [plug3-fires, prereq, engine-starts] &
- add [plug4-fires, prereq, engine-starts] &
- add [cable1-ok, prereq, plug1-fires] &
- add [cable2-ok, prereq, plug2-fires] &
- add [cable3-ok, prereq, plug3-fires] &
- add [cable4-ok, prereq, plug4-fires] &
- add [coil-powered, prereq, X-fires] &
- add [starter-powered, prereq, starter-turning] &
- add [battery-charged, prereq, starter-powered] &
- add [battery-charged, prereq, coil-powered] &
- add [need_to_investigate, engine-starts]. /* set focus of problem */
-
- rule run_it forward
- if
- [need_to_investigate, X] & /* retrieve focus */
- deduce [X,has_root_cause,Obj-State] /* initiate backward-chain */
- then
- announce [Obj,' is a source of difficulty', nl,
- 'so you should fix it and try again.'] &
- halt. /* single fault assumption! */
-
- rule i_am_bad backward
- if
- [observation,X,no] & /* found a troublesome object...*/
- -- [P,prereq,X] /* which has no prerequisite links? */
- then
- [X,has_root_cause,X]. /* then that guy is the root cause! */
-
- rule you_are_bad backward
- if
- [observation,X,no] & /* found a troublesome object X... */
- [P,prereq,X] & /* which DOES have a prerequisite P */
- [P,has_root_cause,Root] /* and P's problems are really due to Root */
- then
- [X,has_root_cause,Root]. /* then attribute X's problems to Root */
-
- rule ask_it backward /* N.B. assumes a yes or no response!!! */
- if
- query ['Is it the case that',Obj-State] receives_answer Ans
- then
- [observation,Obj-State,Ans].